package com.gtt.lazy.controller;

import com.gtt.lazy.domain.ColorCategory;
import com.gtt.lazy.domain.User;
import com.gtt.lazy.service.ColorCategoryService;
import com.gtt.lazy.service.UserService;

public class InitAdmin {

	private UserService userService;
	private ColorCategoryService colorCategoryService;

	public void init() {
		initUser();
		initColorCategory();
	}

	/**
	 * 初始化用户
	 */
	private void initUser() {
		if (userService.existUser("admin")) {
			return;
		}
		userService.add(new User("admin", "111111"));
	}

	/**
	 * 初始化色板类别
	 */
	private void initColorCategory() {
		if (colorCategoryService.list().size() != 0) {
			return;
		}
		colorCategoryService.add(new ColorCategory("麂皮"));
		colorCategoryService.add(new ColorCategory("纯棉"));
		colorCategoryService.add(new ColorCategory("涤棉"));
		colorCategoryService.add(new ColorCategory("其他"));
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public void setColorCategoryService(
			ColorCategoryService colorCategoryService) {
		this.colorCategoryService = colorCategoryService;
	}

}
